package com.opo5.logisticsmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.opo5.logisticsmanagement.Vo.CableVo;
import com.opo5.logisticsmanagement.dao.CablePlanDao;
import com.opo5.logisticsmanagement.domain.CablePlan;
import com.opo5.logisticsmanagement.service.CablePlanService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CablePlanServiceImpl extends ServiceImpl<CablePlanDao, CablePlan> implements CablePlanService {
    @Autowired(required = false)
    private CablePlanDao cablePlanDao;
    @Override
    public IPage<CablePlan> selectPage(int currentPage, int pageSize, CablePlan cablePlan) {
        LambdaQueryWrapper<CablePlan> lqw=new LambdaQueryWrapper<>();
        lqw.eq(cablePlan.getProjectnum()!=null,CablePlan::getProjectnum,cablePlan.getProjectnum());
        lqw.like(Strings.isNotEmpty(cablePlan.getProjectname()),CablePlan::getProjectname,cablePlan.getProjectname());
        lqw.like(Strings.isNotEmpty(cablePlan.getCablename()),CablePlan::getCablename,cablePlan.getCablename());
        lqw.eq(cablePlan.getPlanstate()!=null,CablePlan::getPlanstate,cablePlan.getPlanstate());
        IPage<CablePlan>page=new Page<>(currentPage,pageSize);
        cablePlanDao.selectPage(page,lqw);
        return page;
    }

    @Override
    public Page<CableVo> getPageVo(Page<CableVo> iPage) {
        return cablePlanDao.cable(iPage);
    }
//    public Page<NewVo> getPageVo(Page<NewVo> iPage) {
//        return newDao.newpro(iPage);
//    }
}
